<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue v-for 绑定重复Key警告 </title>
    <style>
        div {
            padding: 10px;
            border: 1px solid green;
        }

        h2 {
            padding: 10px;
            border: 1px solid rgb(228, 95, 210);
        }
    </style>
</head>

<body>
    <div id="app">
        <h2>text here：
            <span>{{message}}</span>
            <span>多点几下试试</span>
        </h2>

        <!-- for 循环绑定key -->
        <ul>
            <li v-for="item in letters" :key="item">{{item}}</li>
        </ul>

        <button v-on:click='action'>点击</button>
    </div>

    <script src="js/vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                message: `当for 遍历绑定key时，如果插入的元素是重复的，控制台会报一个Vue 警告！`,
                letters: ['a', 'b', 'c', 'd'],
            },
            computed: {

            },
            methods: {
                action: function () {
                    this.letters.push('some letters');
                }
            }
        });
    </script>
</body>

</html>